package com.example.redis;

/**
 * @author yuexizhao9159@gmail.com
 * @version V1.0
 * @since 2.2.0 2021/3/6 0006 13:36
 */

import com.example.redis.utils.RedisUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/returnResult")
public class RestFulTestApi {

    @Autowired
    private RedisUtil redisUtil;

    //设置价格
    @GetMapping("/setPrice")
    public String  setPrice(){
        redisUtil.set("price",100);
        return "设置价格成功";
    }


    //获取价格
    @GetMapping("/getPrice")
    public String  getPrice(){
        Object price = redisUtil.get("price");
        int i = Integer.parseInt(price.toString())-1;
        redisUtil.set("price",i);
        return "设置价格成功+"+i+"";
    }

}
